from fastapi import FastAPI
from pywebio.platform.fastapi import asgi_app
from uvicorn import run
import hone
from back.web.pywebioList import pywebioList
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware

app = FastAPI()
app.add_middleware(         # 添加中间件
    CORSMiddleware,         # CORS中间件类
    allow_origins=["*"],  # 允许起源
    allow_credentials=True, # 允许凭据
    allow_methods=["*"],    # 允许方法
    allow_headers=["*"],    # 允许头部
)
optional_arguments = {
        "delimiters": [" ", "_", ","]
    }
Hone = hone.Hone(**optional_arguments)

# @app.post("/pws")
# def get_pws():
#
#     from common.config import userConfig as Config
#     from common.config import getUserConfig
#     print("发起fastApi请求------------------------------------",Config.admin)
#     return getUserConfig().admin

def start8001():
    pywebioApp = asgi_app(pywebioList)
    app.mount("/", pywebioApp)
    run(app, host="0.0.0.0", port=8001)
if __name__=="__main__":
    start8001()
